# -*- coding:utf-8 -*-

from flask_script import Manager
import unittest
from project import app
from project import db
manager = Manager(app)


@manager.command
def recreate_db():
    """
    重新创建数据
    """
    db.drop_all()
    db.create_all()
    db.session.commit()


@manager.command
def test():
    """
    Runs the tests without code coverage.
    """
    tests = unittest.TestLoader().discover('project/tests', pattern='test*.py')
    result = unittest.TextTestRunner(verbosity=2).run(tests)
    if result.wasSuccessful():
        return 0
    return 1


if __name__ == '__main__':
    manager.run()
